<!DOCTYPE html>
<html>
<head>
	<title>Vue.js</title>
	<!-- 引入样式 -->
	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
	<div id="app">	
	<span>{{ message }}</span><br>
	<!-- input  -->
	<el-input v-model="message" placeholder="please input message"></el-input>
		<ul v-for="(item,index) in items">
			<li>{{ item.content }}
					<el-button type="danger" @click="delItem(index)">delete</el-button>
			</li>
		</ul>
		<el-form v-on:submit.prevent='addItem(newTodo)'>
		  <el-form-item label="todo">
		    <el-input v-model="newTodo.content" placeholder="newTodo"></el-input>
		  </el-form-item>
		  <el-form-item>
		    <el-button type="submit" @click="addItem(newTodo)">submit</el-button>
		  </el-form-item>
		</el-form>
	</div>
</body>
	<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
	<!-- 引入组件库 -->
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<script type="text/javascript">
		new Vue({
			el : '#app',
			data : {
				message : 'Hello Vue',
				items : [
					{'id':1,'content':'zhangsan'},
				],
				newTodo : {'id':null,'content':''},
			},
			methods : {
				addItem(newTodo) {
					this.items.push(newTodo)
					this.newTodo = {'id':null,'content':''}
				},
				delItem(index) {
					this.items.splice(index,1)
				}
			}
		})
	</script>
</html>